<?php

namespace App\Http\Controllers\Back;

use App\Models\back\Ajax;
use App\Tool\Tool;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class AjaxController extends Controller
{
	/*
	 * 验证分发器方法
	 *@param    string  $name   要验证的类别名
	 * return   bool
	 */
    public function validator(Request $request, $name)
    {
    	$method = $name.'Validator';
	    $ajaxModel = new Ajax();
    	//模型中方法是否存在
	    if (method_exists ( $ajaxModel , $method)) {
		    $bool = $ajaxModel->$method($request->all());
		    return response()->json($bool);
	    } else {
			return Tool::ajaxReturn(404, '没有找到'.$name.'方法');
	    }
    }
}
